<style type="text/css">
select:not(:checked) {
  color: #33cabb;
}
select option:not(:disabled){
  color: #33cabb;
}
</style>
<div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-toolbar clearfix">
                <form id="so" class="pull-right search-bar" method="post" role="form">
                  <div class="input-group">
                    
                    <input type="text" class="form-control" value="" name="word" placeholder="请输入名称">
                    <div class="input-group-btn">
                      <button class="btn btn-default dropdown-toggle" id="sosend" data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false">
                      搜索网站 
                      </button>
                      
                    </div>
                  </div>
                </form>
                <div class="toolbar-btn-action">
                  <a class="btn btn-primary m-r-5" href="javascript:void(0)" data-toggle="modal" data-target="#exampleModal" data="" class="class_add"><i class="mdi mdi-plus"></i> 新增</a>
                  <a class="btn btn-success m-r-5" href="#!"><i class="mdi mdi-check"></i> 启用</a>
                  <a class="btn btn-warning m-r-5" href="#!"><i class="mdi mdi-block-helper"></i> 禁用</a>
                  <a class="btn btn-danger" href="#!"><i class="mdi mdi-window-close"></i> 删除</a>
                </div>
              </div>
              <div class="card-body">
                
                <div class="table-responsive">
                  <table class="table table-bordered">
                    <thead>
                      <tr>
                        <th>
                          <label class="lyear-checkbox checkbox-primary">
                            <input type="checkbox" id="check-all"><span></span>
                          </label>
                        </th>
                        <th>编号</th>
                        <th>网站名称</th>
                        <th>网站地址</th>
                        <th>所属分类</th>
                        <th>创建者</th>
                        <th>点击量</th>
                        <th>状态</th>
                        <th>操作</th>
                      </tr>
                    </thead>
                    <tbody>
                    <volist name="web" id="v">
                      <tr>
                        <td>
                          <label class="lyear-checkbox checkbox-primary">
                            <input type="checkbox" name="ids[]" value="1"><span></span>
                          </label>
                        </td>
                        <td>{$v.id}</td>
                        <td>{$v.title}</td>
                        <td>{$v.url}</td>
                        <?php $con = M('classify')->where('id='.$v['sid'])->find(); ?>
                        <td>{$con.class_name}</td>
                        <td><?php if($v['uid']==0){echo '管理员';}else{echo '会员';} ?></td>
                        <td>{$v.click}</td>
                        <td><a class=" type" href="javascript:void(0)" data="{$v.id}">
                          <?php if($v['type']==1){
                          echo '<span class="label label-success">显示中</span>';
                        }else{
                        echo '<span class="label label-danger">隐藏中</span>';
                    }?>
            </a></td>
                        <td>
                          <div class="btn-group">
                            <a data-toggle="modal" data-target="#exampleModal"
                            href="javascript:void(0)" class="btn btn-xs btn-default class_add" zid='{$v.id}' ztitle="{$v.title}" zurl="{$v.url}" keywords="{$v.keywords}" description="{$v.description}" sid="{$v.sid}"><i class="mdi mdi-pencil"></i></a>
                            <a data="{$v.id}" class="btn btn-xs btn-default delete" href="javascript:void(0)"  data-original-title="删除"><i class="mdi mdi-window-close"></i></a>
                          </div>
                        </td>
                      </tr>
                  </volist>
                      
                    </tbody>
                  </table>
                </div>
                <ul class="pagination">
                  {$show}
                </ul>
       
              </div>
            </div>
          </div>
          
        </div>
<!--模拟静态框-->
  <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" style="display: none;">
                  <div class="modal-dialog" role="document">
                    <div class="modal-content">
                      <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                        <h4 class="modal-title" id="exampleModalLabel">站点添加</h4>
                      </div>
                      <div class="modal-body">
                        <form id="add_post"  action="" method="post" onsubmit="return false;">
                          <div class="form-group">
                            <label for="recipient-name" class="control-label">网站名称：</label>
                            <input type="text" class="form-control" name="title" id="ztitle">
                          </div>
                        
                         <div class="form-group">
                            <label for="recipient-name" class="control-label">网站链接：</label>
                            <input placeholder="" type="text" class="form-control" name="url" id="zurl">
                          </div>
                          <div class="form-group">
                            <label for="recipient-name" class="control-label">网站关键词：</label>
                            <input type="text" class="form-control" name="keywords" id="keywords">
                          </div>
                          <div class="form-group">
                            <label for="recipient-name" class="control-label">网站描述：</label>
                            <input type="text" class="form-control" id="description" name="description">
                          </div>
                          <div class="form-group">
                            <label for="recipient-name" class="control-label">所属分类：</label>
                            <select class="form-control" id="sid" name="sid">
                         <option>请选择所属分类</option>
                    <volist name="data" id="v">
                        <option value="{$v.id}">{$v.class_name}</option>
                        </volist>

                      </select>
                          </div>
                          <input type="hidden" name="id" id="id">
                          <div class="form-group">
                            <label for="recipient-name" class="control-label">获取网站信息参数设置</label>
                            <label class="lyear-checkbox checkbox-danger m-t-10">
                    <input name="code" value="1" type="checkbox" ><span>如果目标网站是GBK编码勾选此处</span>
                  </label>
                          </div>
                        </form>
                      </div>
                      
                      <div class="modal-footer">

                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary info">获取网站标题</button>
                        <button type="button" class="btn btn-primary send">提交保存</button>
                      </div>
                    </div>
                  </div>
                </div>
<!--模拟静态框-->
<script>
//分页
$('.page').click(function() {
    lightyear.loading('show'); // 显示
    $.ajax({
        type: "POST",
        url: $(this).attr("data"),
        success: function(data) {
            lightyear.loading('hide'); // 隐藏    
            if (data) {
                $("#content").html(data);
                lightyear.loading('hide'); // 隐藏
            } else {
                alert('页面加载失败或异常,请刷新重试');
                lightyear.loading('hide');
            }
        }
    });
});
//添加分类
  $('.class_add').click(function(){
    $('#id').val($(this).attr("zid"));
    $('#ztitle').val($(this).attr("ztitle"));
    $('#zurl').val($(this).attr("zurl"));
    $('#keywords').val($(this).attr("keywords"));
    $('#description').val($(this).attr("description"));
    $("#sid").val($(this).attr("sid"));
  }); 
//提交添加
  $('.send').click(function(){
  lightyear.loading('show');  // 显示
    $.ajax({
    type: "POST",
    url: "{:U('WebData/web_post')}",
    data:$('#add_post').serialize(),
      success: function(data){
        if(data.indexOf('操作成功')>=0){
    lightyear.loading('hide');  // 隐藏 
 
     lightyear.notify('操作成功', 'success', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
        }else{
     lightyear.notify(data, 'danger', 1000);
     lightyear.loading('hide');  // 隐藏 
    }
      }
    });
  });
//获取信息
  $('.info').click(function(){
  lightyear.loading('show');  // 显示
    $.ajax({
    type: "POST",
    url: "{:U('WebData/web_info')}",
    data:$('#add_post').serialize(),
      success: function(data){
        if(data){
        json=eval("("+data+")")
     $('#ztitle').val(json.titles);
    $('#keywords').val(json.keywords);
    $('#description').val(json.description);
    lightyear.loading('hide');  // 隐藏
     lightyear.notify('获取完毕', 'success', 1000, 'mdi mdi-emoticon-happy', 'top', 'center');
        }else{
     lightyear.notify('获取异常请重试', 'danger', 1000);
     lightyear.loading('hide');  // 隐藏 
    }
      }
    });
  });
//删除
  $('.delete').click(function(){
  lightyear.loading('show');  // 显示
    $.ajax({
    type: "POST",
    url: "{:U('WebData/web_del')}", 
    data:'id='+$(this).attr("data"), 
      success: function(data){
        if(data.indexOf('操作成功')>=0){
     lightyear.notify('操作成功', 'success', 500, 'mdi mdi-emoticon-happy', 'top', 'center');
     setTimeout(function() {
          $.ajax({
          type: "POST",
          url: "{$_COOKIE.url}",       
              success: function(data){
                      if(data){
              $("#content").html(data);
              lightyear.loading('hide');  // 隐藏 
            }else{
              alert('页面加载失败或异常,请刷新重试');
              lightyear.loading('hide'); 
            }
              }
          });
          }, 1000);
        }else{
          lightyear.loading('hide');  // 隐藏 
     lightyear.notify(data, 'danger', 1000);
    }
      }
    });
  });
 //改变状态
$('.type').click(function() {
    lightyear.loading('show'); // 显示
    $.ajax({
        type: "POST",
        url: "{:U('WebData/web_type')}",
        data: "id=" + $(this).attr("data"),
        success: function(data) {
            if (data.indexOf('操作成功') >= 0) {
                lightyear.notify('操作成功', 'success', 500, 'mdi mdi-emoticon-happy', 'top', 'center');
                setTimeout(function() {
                    $.ajax({
                        type: "POST",
                        url: "{$_COOKIE.url}",
                        success: function(data) {
                            if (data) {
                                $("#content").html(data);
                                lightyear.loading('hide'); // 隐藏 
                            } else {
                                alert('页面加载失败或异常,请刷新重试');
                                lightyear.loading('hide');
                            }
                        }
                    });

                },100);
            } else {
                lightyear.notify(data, 'danger', 1000);
                lightyear.loading('hide');
            }
        }
    });
});
//搜索
$('#sosend').click(function() {
    lightyear.loading('show'); // 显示
    $.ajax({
        type: "POST",
        data: $('#so').serialize(),
        url: "{:U('WebData/web_so')}",
        success: function(data) {  
            if (data) {
                $("#content").html(data);
                lightyear.loading('hide'); // 隐藏
            } else {
                alert('页面加载失败或异常,请刷新重试');
                lightyear.loading('hide');
            }
        }
    });
});
</script>